package com.software.service;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

/**
 * startActivity();
 *          构造方法（）--->onCreate()--->onStartCommand()
 *          启动之后，没有关闭服务之前，服务一直存在，如果再启动或调用服务相关的方法，都要通过startCommand（）方法
 * stopActivity():
 *          onDestroy()
 *
 * bindService():
 *          构造方法() ---> onCreate() ---> onBind() ---> onServiceConnected()
 * unBindService():
 *
 */
public class LifeService extends Service {
    public LifeService() {
        Log.i("lifeService", "服务实例化");
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.i("lifeService", "服务创建");
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i("lifeService", "服务启动");
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i("lifeService", "服务已销毁");
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.i("lifeService", "onBind()");
        return new Binder();
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.i("lifeService", "onUnbind()");
        return true;
    }
}